package com.jzo2o.customer.controller.worker;

import com.jzo2o.customer.model.dto.request.BankAccountUpsertReqDTO;
import com.jzo2o.customer.model.dto.response.BankAccountResDTO;
import com.jzo2o.customer.service.IBankAccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


/**
 * 服务端设置银行账户
 * @author Shizhicong
 */
@RestController
@RequestMapping("/worker/bank-account")
@Api(tags = "服务端 - 银行账户相关接口")
public class WorkerBankAccountController {

    @Resource
    private IBankAccountService bankAccountService;

    /**
     * 新增或更新银行账号信息
     * @param bankAccountUpsertReqDTO 银行账户新增或更新请求体
     */
    @PostMapping
    @ApiOperation("新增或更新银行账号信息")
    public void upsertBankAccount(@RequestBody BankAccountUpsertReqDTO bankAccountUpsertReqDTO) {
        bankAccountUpsertReqDTO.setType(2);
         bankAccountService.upsertBankAccount(bankAccountUpsertReqDTO);
    }

    /**
     * 获取当前用户银行账号信息
     * @return 银行账号信息
     */
    @GetMapping("/currentUserBankAccount")
    @ApiOperation("获取当前用户银行账号信息")
    public BankAccountResDTO getCurrentUserBankAccount() {
        return bankAccountService.getCurrentUserBankAccount();
    }
}
